<!DOCTYPE html><html lang="cn" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>HustleLr</title><meta name="author" content="HustleLr"><meta name="copyright" content="HustleLr"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta property="og:type" content="website">
<meta property="og:title" content="HustleLr">
<meta property="og:url" content="http://greenfivebird.gitee.io/hustleblog/index.html">
<meta property="og:site_name" content="HustleLr">
<meta property="og:locale">
<meta property="og:image" content="http://greenfivebird.gitee.io/hustleblog/img/head.jpg">
<meta property="article:author" content="HustleLr">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://greenfivebird.gitee.io/hustleblog/img/head.jpg"><link rel="shortcut icon" href="/hustleblog/img/head.jpg"><link rel="canonical" href="http://greenfivebird.gitee.io/hustleblog/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/hustleblog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/hustleblog/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'HustleLr',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2024-04-21 00:33:38'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.1"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">Loading...</div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/hustleblog/img/head.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/hustleblog/archives/"><div class="headline">Articles</div><div class="length-num">17</div></a></div><div class="data-item"><a href="/hustleblog/tags/"><div class="headline">Tags</div><div class="length-num">12</div></a></div><div class="data-item"><a href="/hustleblog/categories/"><div class="headline">Categories</div><div class="length-num">12</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/hustleblog/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/hustleblog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/hustleblog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/hustleblog/link/"><i class="fa-fw fas fa-link"></i><span> 外链</span></a></div><div class="menus_item"><a class="site-page" href="/hustleblog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header" style="background-image: url('/hustleblog/img/top2.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/hustleblog/">HustleLr</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/hustleblog/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/hustleblog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/hustleblog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/hustleblog/link/"><i class="fa-fw fas fa-link"></i><span> 外链</span></a></div><div class="menus_item"><a class="site-page" href="/hustleblog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">HustleLr</h1><div id="site-subtitle"><span id="subtitle"></span></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left"><a href="/hustleblog/2024/04/21/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95Day-2/" title="代码随想录Day 2"><img class="post_bg" src="/hustleblog/img/code.png" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="代码随想录Day 2"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2024/04/21/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95Day-2/" title="代码随想录Day 2">代码随想录Day 2</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2024-04-20T16:31:56.000Z" title="Created 2024-04-21 00:31:56">2024-04-21</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/%E7%AE%97%E6%B3%95/">算法</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/hustleblog/categories/%E7%AE%97%E6%B3%95/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95/">代码随想录</a></span></div><div class="content">代码随想录Day 2前言：这些天有一些忙，在发布第四天任务的时候我才开始完成第二天的任务
任务今天是第二天，任务一共有三道题，分别是977.有序数组的平方，209.长度最小的子数组，59.螺旋矩阵Ⅱ
977.有序数组的平方解法使用双指针法来处理，由于是非递减序列，元素有可能有负数，所以存在负数的平方大于小的正数的平方，所以顺序有可能变化。因为是非递减序列在做双指针的时候要在当前最小的位置一个，最大的位置一个，然后定义一个新数组，头尾进行比较，将比较最大的平方数放入新数组的最大位置。
代码实现1234567891011121314151617181920212223class Solution &#123;    public int[] sortedSquares(int[] nums) &#123;        // 数组长度        int length = nums.length-1;        // 返回的新的数组        int[] result = new int[nums.length];        // 双指针，一个从小的位置，一个从大的位置    ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/hustleblog/2024/04/17/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95Day-1/" title="代码随想录Day 1"><img class="post_bg" src="/hustleblog/img/code.png" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="代码随想录Day 1"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2024/04/17/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95Day-1/" title="代码随想录Day 1">代码随想录Day 1</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2024-04-17T14:26:46.000Z" title="Created 2024-04-17 22:26:46">2024-04-17</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/%E7%AE%97%E6%B3%95/">算法</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/hustleblog/categories/%E7%AE%97%E6%B3%95/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95/">代码随想录</a></span></div><div class="content">代码随想录Day 1前言：这是第一次参加代码随想录的训练营，平常也有在跟着规划刷一些题，但是好多都坚持不下来，这次参加随想录的训练营一定要全程跟下来，希望可以在算法上面有一些进步。在每天的任务中获取到新的知识点，增强记忆和学习方法。
任务今天是第一天，开个好头，今天的任务是学习数组理论基础，题目是力扣的 704. 二分查找，27. 移除元素 
二分查找概念二分查找是一种在有序数组中查找特定元素的高效算法，核心思想是不断将搜索范围对半分割，直到找到目标元素或确定元素不存在。二分查找的时间复杂度为O(log n)，这是基于每次迭代都将搜索范围减半的事实。
需要提前确定能否用二分查找的是：数组一定要是有序的，这是前提
二分查找中需要注意的点有下面几点：

确定查找的区间（也就是搜索范围）
跟目标值进行比对，每次范围变为原来的一半

根据上述规则可以得知：

因为数组在内存地址上是连续的，且下标是从0开始的，那么每次查找的区间左边界一定是有用的，所以有两种区间选择[left,right], [left,right)，一种左右都闭，一种左闭右开。
取中间值，在比对目标值时，适当的调整左边界或右边 ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/hustleblog/2022/07/11/Gateway%E8%AE%B0%E5%BD%95/" title="Gateway记录"><img class="post_bg" src="/hustleblog/img/gateway.webp" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="Gateway记录"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2022/07/11/Gateway%E8%AE%B0%E5%BD%95/" title="Gateway记录">Gateway记录</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-07-11T08:28:45.000Z" title="Created 2022-07-11 16:28:45">2022-07-11</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/SpringCloud/">SpringCloud</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/hustleblog/categories/SpringCloud/Gateway/">Gateway</a></span></div><div class="content">Gateway笔记概述

SpringCloud Gateway是SpringCloud的一个全新项目，给予Spring5.0+Spring Boot2.0和Project Reactor等技术开发的网关，它旨在为微服务架构提供一种简单有效的统一的API路由管理方式。
SpringCloud Gateway是基于WebFlux框架实现的，而WebFlux框架底层则使用了高性能的Reactor模式通信框架Netty，【说穿了就是 SpringCloud Gateway是异步非阻塞式，响应式的框架】


Gateway主要负责反向代理、鉴权、流量控制、熔断、日志监控等
特性SpringCloud Gateway具有如下特性

基于SpringFrameword5，Project Reactor和SpringBoot2.0进行构建；
动态路由：能够匹配任何请求属性
可以对路由指定Predicate（断言）和Filter（过滤器）
集成Hystrix的断路器功能
集成SpringCloud的服务发现功能
易于编写的Predicate（断言）和Filter（过滤器）
请求限流功能
支持路径重写G ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/hustleblog/2022/04/01/%E6%9E%84%E5%BB%BA%E4%BA%8C%E5%8F%89%E6%A0%91/" title="构建二叉树"><img class="post_bg" src="/hustleblog/img/%E4%BA%8C%E5%8F%89%E6%A0%91.webp" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="构建二叉树"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2022/04/01/%E6%9E%84%E5%BB%BA%E4%BA%8C%E5%8F%89%E6%A0%91/" title="构建二叉树">构建二叉树</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-03-31T16:29:49.000Z" title="Created 2022-04-01 00:29:49">2022-04-01</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/%E7%AE%97%E6%B3%95/">算法</a></span></div><div class="content">构建二叉树概念二叉树是一种树形结构，它的特点在于每个节点最多拥有两棵子树（即二叉树中不存在度大于2的结点），并且二叉树的子树有左右之分，次序不能随意颠倒。
性质二叉树有以下几种特性

在二叉树的第i层上最多拥有$2^{i-1}$个结点($i{&gt;=}1$)
在深度为k的二叉树中最多拥有$2^k-1$个结点($k{&gt;=}1$)
对任何一颗二叉树T，如果其中断结点数为$n_0$, 度为2的结点数为$n_2$, 则$n_0=n_2+1$

存储结构在JAVA中可以定义一个类，相当于C语言中的结构体，采用链式存储结构的方式表达，在完全二叉树的情况下也可以用一组地址连续的存储单元依次从上而下，从左到右存储完全二叉树上的所有结点元素。
123456789101112131415161718192021/** * 二叉树结构定义 * @author lrwang * @version 1.0 * @date 2022/3/31 17:55 */public class TreeNode &#123;    int val;    /**     * 左子树     */    TreeNo ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/hustleblog/2022/03/22/Java%E5%B8%B8%E8%A7%81%E5%87%A0%E7%A7%8D%E6%8E%92%E5%BA%8F/" title="Java常见几种排序"><img class="post_bg" src="/hustleblog/img/sort.webp" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="Java常见几种排序"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2022/03/22/Java%E5%B8%B8%E8%A7%81%E5%87%A0%E7%A7%8D%E6%8E%92%E5%BA%8F/" title="Java常见几种排序">Java常见几种排序</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-03-22T09:51:45.000Z" title="Created 2022-03-22 17:51:45">2022-03-22</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/java/">java</a></span></div><div class="content">一、什么是排序算法1、定义排序就是对一整个序列对象根据某个特征或关键字进行排序。
2、术语说明
稳定：如果a原来在b前面，而a=b，排序之后a仍然在b前面
不稳定：如果a原来在b前面，而a=b，排序后a可能会在b后面
内排序：所有排序操作都在内存中完成
外排序：因为数据量太大，要把数据放在磁盘中，而排序需要通过磁盘和内存之间数据传输才能完成
时间复杂度：一个算法执行所消费的时间
空间复杂度：程序所需内存大小

3、表格



排序算法
平均时间复杂度
最好情况
最坏情况
空间复杂度
排序方式
稳定性




冒泡排序
$O(n^2)$
$O(n)$
$O(n^2)$
$O(1)$
In-place
稳定


选择排序
$O(n^2)$
$O(n^2)$
$O(n^2)$
$O(1)$
In-place
不稳定


插入排序
$O(n^2)$
$O(n)$
$O(n^2)$
$O(1)$
In-place
稳定


希尔排序
$O(n \log n)$
$O(n \log^2 n)$
$O(n \log^2 n)$
$O(1)$
In-place
不稳定


归并排序
$O(n \log ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/hustleblog/2022/03/20/CPU%E5%8D%A0%E7%94%A8%E8%BF%87%E9%AB%98/" title="CPU占用过高"><img class="post_bg" src="/hustleblog/img/cpu.webp" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="CPU占用过高"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2022/03/20/CPU%E5%8D%A0%E7%94%A8%E8%BF%87%E9%AB%98/" title="CPU占用过高">CPU占用过高</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-03-20T14:20:43.000Z" title="Created 2022-03-20 22:20:43">2022-03-20</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/%E6%97%A5%E5%BF%97/">日志</a></span></div><div class="content">CPU占用过高排查如何排查linux中cpu占用率过高一、查看进程占用CPU百分比1、top命令查看进程

2、查看该进程所有线程占用CPU的情况
12top -Hp &lt;PID&gt;			# 查看线程IDprintf %x &lt;线程ID&gt;		# 将线程ID转化为16进制

因为堆栈信息展示的是16进制的，所以需要把线程id转换成16进制

3、查看堆栈信息
1jstack &lt;进程号&gt; | grep &lt;十六进制线程ID&gt;

4、查看进程GC情况
1jstat -gcutil &lt;进程号&gt; &lt;统计间隔毫秒&gt; &lt;统计次数&gt;

5、查看堆内存
1jmap -heap &lt;进程ID&gt;
查看进程堆内存是否要溢出了，特别是老年代使用情况达到阈值之后会触发Full Gc

6、输出dump文件，借助工具查看程序实例个数
1jmap -dump:format=b,file=&lt;filename&gt; &lt;PID&gt; # 导出某进程下内存heap到文件中
可以通过jdk自带的visualvm 进行分析
</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/hustleblog/2022/03/06/JUC%E5%9F%BA%E7%A1%80/" title="JUC基础"><img class="post_bg" src="/hustleblog/img/juc.jpeg@h_1280" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="JUC基础"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2022/03/06/JUC%E5%9F%BA%E7%A1%80/" title="JUC基础">JUC基础</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-03-06T15:05:35.000Z" title="Created 2022-03-06 23:05:35">2022-03-06</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B/">并发编程</a></span></div><div class="content">JUC编程JUC概述和进程线程概念进程与线程一、进程是计算机中的程序关于某数据集合上的一次运行活动，是系统进行资源分配和调度的基本单位，是操作系统结构的基础。进程是线程的容器。进程是程序的实体。
二、线程是操作系统能够进行运算调度的最小单位。被包含在进程之中，是进程中的实际运作单位。一个进程中可以并发多个线程，每条线程并行执行不同的任务。
线程的状态一、线程状态new——&gt;新建
runnable——-&gt;准备就绪
blocked———&gt;阻塞
wating——-&gt;不见不见
time_wating——&gt;过时不候
terminated————&gt;终结
二、wait和sleep
sleep是Thread的静态方法，wait是Object的方法，任何对象实例都能调用
sleep不会释放锁，也不需要占用锁。wait会释放锁，但是调用它的前提是当前线程占有锁(即代码要在synchronized中)
他们都可以被interrupted方法中断。

并发与并行串行模式是按顺序执行，并行是一起执行。
并发：同一个时刻多个线程访问同一个资源，多个线程对一个点
并行：多项工作一 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/hustleblog/2022/03/06/docker%E6%93%8D%E4%BD%9C/" title="docker操作"><img class="post_bg" src="/hustleblog/img/docker.webp" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="docker操作"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2022/03/06/docker%E6%93%8D%E4%BD%9C/" title="docker操作">docker操作</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-03-06T15:05:21.000Z" title="Created 2022-03-06 23:05:21">2022-03-06</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/%E4%B8%AD%E9%97%B4%E4%BB%B6/">中间件</a></span></div><div class="content">Docker官网：https://www.docker.com/官网文档：下拉最后Docs（Docker手册） 找手册选引擎查看安装文档
Docker安装1.卸载旧版本12345678yum remove docker \                  docker-client \                  docker-client-latest \                  docker-common \                  docker-latest \                  docker-latest-logrotate \                  docker-logrotate \                  docker-engine
2.需要的安装包1yum install -y yum-utils
3.设置镜像仓库（使用阿里云镜像地址）1yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/hustleblog/2022/03/03/%E5%88%86%E5%B8%83%E5%BC%8F%E9%94%81/" title="分布式锁"><img class="post_bg" src="/hustleblog/img/suo.jfif" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="分布式锁"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2022/03/03/%E5%88%86%E5%B8%83%E5%BC%8F%E9%94%81/" title="分布式锁">分布式锁</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-03-03T12:44:15.000Z" title="Created 2022-03-03 20:44:15">2022-03-03</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/%E5%88%86%E5%B8%83%E5%BC%8F/">分布式</a><i class="fas fa-angle-right article-meta-link"></i><a class="article-meta__categories" href="/hustleblog/categories/%E5%88%86%E5%B8%83%E5%BC%8F/%E9%94%81/">锁</a></span></div><div class="content">分布式锁概念什么是分布式锁在很多场景中，我们为了保证数据的最终一致性，需要一些方案来支持，比如分布式事务、分布式锁等，他的实现有很多种方式。
一、为什么使用分布式锁在单机应用中，如果需要对某一个共享变量进行多线程同步访问时，可以用到锁和一些机制来处理，但是在集群情况下，一个服务需要部署到几台服务器上通过负载均衡来访问，这时单机中的锁就会不起作用了，所以需要一个能处理集群情况下多线程访问共享变量却仍然能保证数据一致性的机制，就是分布式锁。
二、分布式锁应具备哪些条件1、在分布式系统环境下，一个方法在同一时间只能被一个机器的一个线程执行；2、高可用的获取锁与释放锁；3、高性能的获取锁与释放锁；4、具备可重入特性；5、具备锁失效机制，防止死锁；6、具备非阻塞锁特性，即没有获取到锁将直接返回获取锁失败
三、分布式锁的三种实现方式分布式场景中的数据一致性问题一直是重要的话题，分布式有一个很重要的理论是CAP，而任何一个分布式系统都无法同时满足CAP三个（Consistency 一致性、Availability 可用性、Partition tolerance 分区容错性），最多只能同时满足两项，所 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/hustleblog/2022/03/01/jvm%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/" title="jvm基础知识"><img class="post_bg" src="/hustleblog/img/jvm.jfif" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="jvm基础知识"></a></div><div class="recent-post-info"><a class="article-title" href="/hustleblog/2022/03/01/jvm%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/" title="jvm基础知识">jvm基础知识</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2022-03-01T12:37:31.000Z" title="Created 2022-03-01 20:37:31">2022-03-01</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/hustleblog/categories/java/">java</a></span></div><div class="content"></div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span><a class="page-number" href="/hustleblog/page/2/#content-inner">2</a><a class="extend next" rel="next" href="/hustleblog/page/2/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/hustleblog/img/head.jpg" onerror="this.onerror=null;this.src='/hustleblog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">HustleLr</div><div class="author-info__description"></div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/hustleblog/archives/"><div class="headline">Articles</div><div class="length-num">17</div></a></div><div class="card-info-data-item"><a href="/hustleblog/tags/"><div class="headline">Tags</div><div class="length-num">12</div></a></div><div class="card-info-data-item"><a href="/hustleblog/categories/"><div class="headline">Categories</div><div class="length-num">12</div></a></div></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>Announcement</span></div><div class="announcement_content">Welcome to Wlr's Blog</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/hustleblog/2024/04/21/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95Day-2/" title="代码随想录Day 2"><img src="/hustleblog/img/code.png" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="代码随想录Day 2"/></a><div class="content"><a class="title" href="/hustleblog/2024/04/21/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95Day-2/" title="代码随想录Day 2">代码随想录Day 2</a><time datetime="2024-04-20T16:31:56.000Z" title="Created 2024-04-21 00:31:56">2024-04-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/hustleblog/2024/04/17/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95Day-1/" title="代码随想录Day 1"><img src="/hustleblog/img/code.png" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="代码随想录Day 1"/></a><div class="content"><a class="title" href="/hustleblog/2024/04/17/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95Day-1/" title="代码随想录Day 1">代码随想录Day 1</a><time datetime="2024-04-17T14:26:46.000Z" title="Created 2024-04-17 22:26:46">2024-04-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/hustleblog/2022/07/11/Gateway%E8%AE%B0%E5%BD%95/" title="Gateway记录"><img src="/hustleblog/img/gateway.webp" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="Gateway记录"/></a><div class="content"><a class="title" href="/hustleblog/2022/07/11/Gateway%E8%AE%B0%E5%BD%95/" title="Gateway记录">Gateway记录</a><time datetime="2022-07-11T08:28:45.000Z" title="Created 2022-07-11 16:28:45">2022-07-11</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/hustleblog/2022/04/01/%E6%9E%84%E5%BB%BA%E4%BA%8C%E5%8F%89%E6%A0%91/" title="构建二叉树"><img src="/hustleblog/img/%E4%BA%8C%E5%8F%89%E6%A0%91.webp" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="构建二叉树"/></a><div class="content"><a class="title" href="/hustleblog/2022/04/01/%E6%9E%84%E5%BB%BA%E4%BA%8C%E5%8F%89%E6%A0%91/" title="构建二叉树">构建二叉树</a><time datetime="2022-03-31T16:29:49.000Z" title="Created 2022-04-01 00:29:49">2022-04-01</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/hustleblog/2022/03/22/Java%E5%B8%B8%E8%A7%81%E5%87%A0%E7%A7%8D%E6%8E%92%E5%BA%8F/" title="Java常见几种排序"><img src="/hustleblog/img/sort.webp" onerror="this.onerror=null;this.src='/hustleblog/img/404.jpg'" alt="Java常见几种排序"/></a><div class="content"><a class="title" href="/hustleblog/2022/03/22/Java%E5%B8%B8%E8%A7%81%E5%87%A0%E7%A7%8D%E6%8E%92%E5%BA%8F/" title="Java常见几种排序">Java常见几种排序</a><time datetime="2022-03-22T09:51:45.000Z" title="Created 2022-03-22 17:51:45">2022-03-22</time></div></div></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>Categories</span>
            <a class="card-more-btn" href="/hustleblog/categories/" title="More">
    <i class="fas fa-angle-right"></i></a>
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/hustleblog/categories/SpringCloud/"><span class="card-category-list-name">SpringCloud</span><span class="card-category-list-count">1</span></a><ul class="card-category-list child"><li class="card-category-list-item "><a class="card-category-list-link" href="/hustleblog/categories/SpringCloud/Gateway/"><span class="card-category-list-name">Gateway</span><span class="card-category-list-count">1</span></a></li></ul></li><li class="card-category-list-item "><a class="card-category-list-link" href="/hustleblog/categories/java/"><span class="card-category-list-name">java</span><span class="card-category-list-count">3</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/hustleblog/categories/%E4%B8%AD%E9%97%B4%E4%BB%B6/"><span class="card-category-list-name">中间件</span><span class="card-category-list-count">4</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/hustleblog/categories/%E5%88%86%E5%B8%83%E5%BC%8F/"><span class="card-category-list-name">分布式</span><span class="card-category-list-count">1</span></a><ul class="card-category-list child"><li class="card-category-list-item "><a class="card-category-list-link" href="/hustleblog/categories/%E5%88%86%E5%B8%83%E5%BC%8F/%E9%94%81/"><span class="card-category-list-name">锁</span><span class="card-category-list-count">1</span></a></li></ul></li><li class="card-category-list-item "><a class="card-category-list-link" href="/hustleblog/categories/%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B/"><span class="card-category-list-name">并发编程</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/hustleblog/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/"><span class="card-category-list-name">开发工具</span><span class="card-category-list-count">1</span></a></li>
            </ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>Tags</span></div><div class="card-tag-cloud"><a href="/hustleblog/tags/SpringCloud/" style="font-size: 1.1em; color: #999">SpringCloud</a> <a href="/hustleblog/tags/java%E5%9F%BA%E7%A1%80/" style="font-size: 1.23em; color: #999ea6">java基础</a> <a href="/hustleblog/tags/%E4%B8%AD%E9%97%B4%E4%BB%B6/" style="font-size: 1.5em; color: #99a9bf">中间件</a> <a href="/hustleblog/tags/%E5%88%86%E5%B8%83%E5%BC%8F/" style="font-size: 1.1em; color: #999">分布式</a> <a href="/hustleblog/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" style="font-size: 1.1em; color: #999">多线程</a> <a href="/hustleblog/tags/%E5%BA%95%E5%B1%82/" style="font-size: 1.1em; color: #999">底层</a> <a href="/hustleblog/tags/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/" style="font-size: 1.1em; color: #999">开发工具</a> <a href="/hustleblog/tags/%E6%97%A5%E5%BF%97/" style="font-size: 1.1em; color: #999">日志</a> <a href="/hustleblog/tags/%E7%AE%97%E6%B3%95/" style="font-size: 1.37em; color: #99a4b2">算法</a> <a href="/hustleblog/tags/%E8%AF%AD%E8%A8%80/" style="font-size: 1.1em; color: #999">语言</a> <a href="/hustleblog/tags/%E9%94%81/" style="font-size: 1.1em; color: #999">锁</a> <a href="/hustleblog/tags/%E9%9D%A2%E8%AF%95%E9%A2%98/" style="font-size: 1.23em; color: #999ea6">面试题</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>Archives</span></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/hustleblog/archives/2024/04/"><span class="card-archive-list-date">April 2024</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/hustleblog/archives/2022/07/"><span class="card-archive-list-date">July 2022</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/hustleblog/archives/2022/04/"><span class="card-archive-list-date">April 2022</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/hustleblog/archives/2022/03/"><span class="card-archive-list-date">March 2022</span><span class="card-archive-list-count">9</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/hustleblog/archives/2021/07/"><span class="card-archive-list-date">July 2021</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/hustleblog/archives/2021/06/"><span class="card-archive-list-date">June 2021</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/hustleblog/archives/2021/04/"><span class="card-archive-list-date">April 2021</span><span class="card-archive-list-count">1</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>Info</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">Article :</div><div class="item-count">17</div></div><div class="webinfo-item"><div class="item-name">Last Push :</div><div class="item-count" id="last-push-date" data-lastPushDate="2024-04-20T16:33:37.992Z"></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/hustleblog/img/top2.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2024 By HustleLr</div><div class="footer_custom_text">Welcome to HustleLr's Blog</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="Toggle Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="Back To Top"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/hustleblog/js/utils.js"></script><script src="/hustleblog/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function subtitleType () {
  if (true) { 
    window.typed = new Typed("#subtitle", {
      strings: ["有志者&#44;事竟成","Where there is a will, there is a way","今日事&#44;今日毕","Never put off till tomorrow what you can do today","行百里者半九十","The last leg of a journey marks the halfway point"],
      startDelay: 300,
      typeSpeed: 150,
      loop: true,
      backSpeed: 50
    })
  } else {
    document.getElementById("subtitle").innerHTML = '有志者&#44;事竟成'
  }
}

if (true) {
  if (typeof Typed === 'function') {
    subtitleType()
  } else {
    getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
  }
} else {
  subtitleType()
}</script></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="true"></script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js" data-mobile="false" data-text="有,志,者,事,竟,成" data-fontsize="15px" data-random="false" async="async"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>